# _*_ coding : utf-8 _*_
import urllib.request
import ssl
import json
import time

# 关闭证书认证
ssl._create_default_https_context = ssl._create_unverified_context


def getlist() -> object:
    # date = input('你要查询的日期(格式:1111-22-33):')
    data0 = urllib.request.urlopen(f"https://kyfw.12306.cn/otn/leftTicket/query?leftTicketDTO.train_date=2017-02-28&leftTicketDTO.from_station=HOY&leftTicketDTO.to_station=CSQ&purpose_codes=ADULT", ).read()
    data1 = json.loads(data0)
    return data1['data']

data_ = getlist()

# print('**********列车车次表**********')
# for x in data_:
#     print(x['queryLeftNewDTO']['station_train_code'], end='\t')
#
# print('\n')
# choose = input('你想看的车次信息;').upper()
#
# for x in data_:
#     train_information = x['queryLeftNewDTO']['station_train_code']
#     if train_information == choose:
#         print(train_information)
#         print(f"硬卧:{x['queryLeftNewDTO']['yw_num']}\t 硬座:{x['queryLeftNewDTO']['yz_num']}\t 无座:{x['queryLeftNewDTO']['wz_num']}")
#
#
# # getlist()
